// import { PageContainer } from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table';
import { PageContainer } from '@ant-design/pro-layout';
import {getTrailers} from '@/services/trailer/api'

const columns = [
    {
      dataIndex: 'index',
      valueType: 'indexBorder',
      width: 48,
    },
    {
      title: '拖车号',
      dataIndex: 'trailer_ID',
    },
    {
      title: '状态',
      dataIndex: 'state',
      search: false,        // 关闭搜索，默认是开启搜索的
      filters: true,        // 筛选菜单选项
      onFilter: true,       // 确定筛选的运行函数
      valueType: 'select',  // 此行代码不知道什么意思
      valueEnum: {
        all: { text: '全部', status: 'Default' },
        1: {
          text: '在线',
          status: 'Success',
        },
        2: {
          text: '离线',
          status: 'Processing',
          // disabled: true,
        },
        0: {
          text: '断线',
          status: 'Error',
        },
      },
    },
    {
      title: '正在执行的指令',
      dataIndex: 'command',
      search: false,
    },
    {
      title: '开始时刻',
      dataIndex: 'start_time',
      search: false,
    },
    {
      title: '在线时长',
      dataIndex: 'total_time',
      search: false,
    },
];


export default () => {
  return (
    <PageContainer>
      <ProTable 
        columns={columns}
        headerTitle="拖车信息表"
        request={async (params = {}, sort, filter) => {
          // console.log(params, sort, filter);
          const options = {params}
          return getTrailers(options);
        }}
      />
    </PageContainer>
  )
};